﻿using Kevin.Shop.Business.Core.Components.Responser;
using Kevin.Shop.Business.Service.Entity.Helper;
using Kevin.Shop.Business.Service.Entity.SalesManagement.PromotionCode;
using RiderShop.Mobile.Common.Component;
using RiderShop.Mobile.Modle.MyAccount;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace RiderShop.WebSite.Controllers.MyAccount
{
    public partial class MyAccountController : ThemeController
    {
        #region Get User Promotion Code List
        /// <summary>
        /// 得到用户的优惠券
        /// </summary>
        /// <param name="pageIndex">页索引</param>
        /// <param name="status">状态 0 未过期|1已使用|2已过期</param>
        /// <param name="promotionType">优惠类型 0 代金券|1 红包</param>
        /// <returns>优惠券列表</returns>
        [Authorize]
        [HttpGet]
        public ActionResult MyPromotionCode(int pageIndex = 0, int status = 0, int promotionType = 0)
        {
            MyPromotionCodeModel myPromotionCodeModel = new MyPromotionCodeModel();
            myPromotionCodeModel.GetUserPromotionCodes(pageIndex, WebClientContext.CON_PageSize, status, promotionType);

            return View(WebClientContext.Current.SiteTheme, "MyAccount", "MyPromotionCode", WebClientContext.Current.CacheKeyDefaultMasterPage, myPromotionCodeModel);
        }

        /// <summary>
        /// 得到用户的优惠券
        /// </summary>
        /// <param name="pageIndex">当前页的索引</param>
        /// <param name="status">状态 0 未过期|1已使用|2已过期</param>
        /// <param name="promotionType">优惠类型 0 代金券|1 红包</param>
        /// <returns>优惠券列表</returns>
        [HttpGet]
        public ActionResult MyPromotionCodeByAjaxRequest(int pageIndex, int status, int promotionType)
        {
            MyPromotionCodeModel myPromotionCodeModel = new MyPromotionCodeModel();
            myPromotionCodeModel.GetUserPromotionCodes(pageIndex, WebClientContext.CON_PageSize, status, promotionType);

            return PartialView("MyPromotionCodePartial", myPromotionCodeModel);
        }
        #endregion
    }
}
